// Xampler, a MIDI-driven sampler
// Copyright (C) 2006 Nick Thomas
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; either version 2 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
// 02110-1301 USA.

#ifndef XAMPLER_INSTRUMENT_HPP
#define XAMPLER_INSTRUMENT_HPP

// Holds the information and sample list for one instrument.

#include "Sample.hpp"
#include <glibmm/object.h>
#include <glibmm/ustring.h>

namespace xampler
{
    const int MAX_SAMPLES = 128;

    class Instrument : public Glib::Object
    {
    public:
        Instrument();
        ~Instrument();

        // Get/set the instrument's ID number (0 through 15). This is
        // also the MIDI channel that the instrument listens to.
        void set_number(int number) { m_number = number; }
        int get_number() { return m_number; }

        // Get/set the instrument's (user-provided) name.
        Glib::ustring get_name() { return m_name; }
        void set_name(Glib::ustring name) { m_name = name; }

        // Returns the sample at the given number in the instrument.
        Sample *get_sample(int number) { return m_samples[number]; }

        // Sets the sample at the given number in the instrument.
        void set_sample(int number, Sample *sample);

        // Removes any sample at the given number in the
        // instrument. Returns true if a sample was removed, and false
        // otherwise.
        bool remove_sample(int number);

        // Clears all data.
        void clear();

    private:
        Glib::ustring m_name;
        int m_number;
        Sample *m_samples[MAX_SAMPLES];
    };
}

#endif
